package com.example.sofa_module;

import android.util.Log;
import android.view.View;

import androidx.lifecycle.Observer;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.viewbinding.ViewBinding;

import com.example.common.field.DataActionEntity;
import com.example.common.mvvm.view.BaseFragment;
import com.example.sofa_module.databinding.SofaFragmentBinding;
import com.example.sofa_module.databinding.TagSofaFragmentBinding;
import com.example.sofa_module.entity.TagDataXEntity;

import java.util.ArrayList;
import java.util.List;

public class TagSofaFragment extends BaseFragment<TagSofaFragmentBinding,SofaViewModel> {
    List<TagDataXEntity> data=new ArrayList<>();
    SofaAdapter sofaAdapter=new SofaAdapter();

    @Override
    public View bindLayout() {
        return v.getRoot();
    }

    @Override
    public ViewBinding initBinding() {
        return TagSofaFragmentBinding.inflate(inflater);
    }

    @Override
    public void initView() {
        v.tagRecycle.setLayoutManager(new LinearLayoutManager(getContext()));
    }

    @Override
    public void initData() {
        vm.getUiDataFunction().getUiData().observe(this, new Observer<DataActionEntity>() {
            @Override
            public void onChanged(DataActionEntity entity) {
                Log.i("tagaction", "onChanged: "+entity.action);
                if (entity.action.equals("sofa")){

                    data= (List<TagDataXEntity>) entity.data.get("data");
//                   v.tagRecycle.setAdapter();
                }
            }
        });
    }
}
